package team.ttorder.ttorder.mymapper;

import java.util.Properties;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import tk.mybatis.spring.mapper.MapperScannerConfigurer;


@Configuration
public class MyMabtisMapperScannerConfigure {

	@Bean
	public MapperScannerConfigurer mapperScannerConfigurer() {
		MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
		mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
		// 扫描该路径下的dao
		mapperScannerConfigurer.setBasePackage("team.ttorder.ttorder.dao");
		//设置通用Mapper的属性
		Properties properties = new Properties();
		// 通用dao，需要单独放到一个包里面，不能跟其他mapper文件放到一起
		properties.setProperty("mappers", "team.ttorder.ttorder.mymapper.MyMapper");
		//notEmpty：insert和update中，是否判断字符串类型!=''，少数方法会用到
		properties.setProperty("notEmpty", "false");
		//取回主键的方式
		properties.setProperty("IDENTITY", "MYSQL");
		mapperScannerConfigurer.setProperties(properties);
		return mapperScannerConfigurer;
	}
	
	
}
